import wx

class PreferencesPanel(wx.Panel):
    '''Base class for all config panels in the UI'''
    def __init__(self, parent=None, *args, **kwargs):
        self.tree_item = None
        wx.Panel.__init__(self, parent, *args, **kwargs)

    def GetTitle(self):
        location = getattr(self, "location", ("Preferences"))
        title = getattr(self, "title", self.location[-1])
        return title

    def Separator(self, parent, title):
        '''Creates a simple horizontal separator with title'''
        container = wx.Panel(parent, wx.ID_ANY)
        label = wx.StaticText(container, wx.ID_ANY, label=title)
        sep = wx.StaticLine(container, wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(label, 0, wx.EXPAND|wx.TOP, 8)
        sizer.Add(sep, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 2)
        container.SetSizerAndFit(sizer)
        return container
